package com.apple1.blogweb.controllers;

import com.apple1.blogentity.vo.ArticleVo;
import com.apple1.blogservices.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类的作用、说明信息
 * @author huangliwei
 * @date   2019年1月20日
 */
@RestController
@RequestMapping(value = "/article/")
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @GetMapping("add")
    public String getArticle(){

        ArticleVo articleVo = new ArticleVo();
        articleVo.setUserId(1);
        articleVo.setTitle("今天是来测试标题");
        articleVo.setContent("bubububui");
        articleVo.setWordNumber(20);

        articleService.addArticle(articleVo);

        return "ok";
    }

    @GetMapping("list")
    public  List<ArticleVo> listArticle(){


        List<ArticleVo> list = articleService.selectUserAllArticles(1);

        return list;
    }
}
